define(function (require,exports,module) {
    var sTpl = require("./template.html");
        require("./flyRequestManager.css");
     var flyRequest = require("../flyRequest/flyRequest.js");
     var VueComponent = Vue.extend({

        template: sTpl,
        components:{
            'flyRequest':flyRequest
        },
        data:function () {

            return {
                form: {
                    startDate:'',
                    endDate:'',
                    filter :'',
                    status:''
                },
                planes:[],
                rooms:[],
                enterOpen:true,
                enterData:{
                    editOrAdd:'add'
                },
                childData:{}
                ,
                sigIns:[],
                slidingWindowVisible1:false,
                url:basepath+"/api/flyRequest/query"
            }
        },methods:{
            querySignInService:function () {
               var url=basepath+"/api/flyRequest/query?filter="+this.form.filter+"&startDate="+this.form.startDate
               +"&endDate="+this.form.endDate+"&status="+this.form.status;
               if(this.url==url){
                   this.$refs.flightPlane.freshTableList();
               }
               this.url= url;
            },openSide:function () {
                if(!this.slidingWindowVisible1)
                    this.slidingWindowVisible1 = true;
            },processor:function(data){
                data.forEach(function(da){
                    da.remindIng=false;
                })
                this.sigIns=data;
                return data;
            },
            openEnter:function (val) {
                if(!val){
                    this.$refs.flightPlane.freshTableList();
                }
                this.enterOpen=!val;
                $("#panel-activer").prop("checked",val);
            },
             add:function () {
                 this.childData.edit=false;
                 this.openEnter(true);
             },
            edit:function (scope) {
                this.childData.edit=true
                this.openEnter(true);
                this.$refs.flyRequest.sizeForm= scope.row;
                this.$refs.flyRequest.sizeForm.fileList=[{name:scope.row.name,url:scope.row.url,percentage:0,
                status:"finished",
                uid:scope.row.messageId}];
                this.$refs.flyRequest.sizeForm.bakFileList=[{name:scope.row.bakName,url:scope.row.bakUrl,percentage:0,
                status:"finished",
                    uid:scope.row.messageId}];

            },
                pickEndDate:function (val) {
                  if(!val){
                      this.form.endDate= '';
                  }else{
                      this.form.endDate= val;
                  }

                },
                pickStartDate:function (val) {
                    if(!val){
                        this.form.startDate= '';
                    }else{
                        this.form.startDate= val;
                    }

                }
            ,
            checkedOut:function(scope){
                var $this = this;
                this.$confirm('确定要退房么？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'success'
                }).then(function() {
                    scope.room.roomStatus="1";
                    axios.post(basepath+'/api/room/saveRoom',scope.room)
                        .then(function (response) {
                           // $this.$refs.flightPlane.internalData.splice(scope.$index,1);
                            $this.$notify({
                                title: '退房成功',
                                message: '退房成功'
                            });
                        });
                });
            },serviceEnd:function(scope,index){
                var $this = this;

                this.$confirm('确定要结束么？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'success'
                }).then(function() {
                    if(scope.room){
                        scope.room.roomStatus="1";
                    }
                    scope.serviceStatus="服务结束";
                    scope.passengerStatus="end";
                    axios.post(basepath+"/api/signIn/save", {signInPo:scope, appointmentPo:{}}).then(function (response) {
                        scope.remindIng=false;
                         $this.$refs.flightPlane.internalData.splice(scope.$index,1);
                        $this.$notify({tittle:"保存成功",message:"服务已结束"})
                    })
                });
            }


        },
         created:function () {

            var $this=this;
            axios.get("/dam/api/flightInfo/queryFlightInfo?filter=").then(function (response) {
                $this.planes=response.data;
            })
            axios.get("/dam/api/room/queryRoom?filter=").then(function (response) {
                $this.rooms=response.data;

            })
        },
         activated:function () {
             messages.$emit('change','签入管理');
         }

    })
    module.exports=VueComponent;
    module.exports.reDefine=function (val) {
        module.exports.type=val;
        return module.exports;
    }

})